package com.photologics.main;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SelectLogic_item_Adapter extends BaseAdapter {

	private Context context;
	private final String[] logicname;
	private final int[] completeness;

	public SelectLogic_item_Adapter(Context context, String[] logicname,
			int[] completeness) {

		this.context = context;
		this.logicname = logicname;
		this.completeness = completeness;

	}

	@Override
	public int getCount() {
		return logicname.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View gridLayout_selectlogic;
		
		if (convertView == null) {

			gridLayout_selectlogic = new View(context);
			gridLayout_selectlogic = inflater.inflate(
					R.layout.select_logic_item, null);

			TextView neme_textview = (TextView) gridLayout_selectlogic
					.findViewById(R.id.textview_logic_item_name);

			neme_textview.setText(logicname[position]);

			TextView completeness_textview = (TextView) gridLayout_selectlogic
					.findViewById(R.id.textview_logic_item_completeness);

			completeness_textview.setText(Integer
					.toString(completeness[position]) + "%");

		} else {

			gridLayout_selectlogic = convertView;
		}

		return gridLayout_selectlogic;
	}

}
